'use strict'

let makeId = require('./node_modules/psqlorm/makeId.js')

let uuidSerial = makeId.serialId

function uuid(short_mode=false) {
  if (short_mode) {
    let id = uuidSerial(18)

    return id.substring(0,8) + '-' + id.substring(8,10) + '-' + id.substring(10,12) + '-'
          + id.substring(12, 14) + '-' + id.substring(14,18)
  }

  let id = uuidSerial(20)

  return id.substring(0,8) + '-' + id.substring(8,12) + '-' + id.substring(12,16) + '-' + id.substring(16, 20)
          + '-' + makeId(12)
}

module.exports = uuid

